import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: Anastasia
 * Date: 12.12.14
 * Time: 9:35
 * To change this template use File | Settings | File Templates.
 */
public class Frame extends JFrame {


    private int select;



    private JButton addEmployee  ;               
    private JButton removeEmployee;              
    private JButton getEmployee;                  
    private JButton addDepartment;                 
    private JButton saveList;                     
    private JButton loadlist;                     
    private  JPanel panel;                       

    private JButton  employeeList;

    private JButton departmentList;



    private JButton addEmployeeTwo;



    public Frame()
    {

        super("Client");//Заголовок окна

        setBounds(300,300,450,400);
        panel = new JPanel();

        panel.setLayout(null);
        addEmployee = new JButton("Добавить сотрудника");
        addEmployee.setBounds(5, 5, 200, 30);
        panel.add(addEmployee);


        addDepartment = new JButton("Добавить отдел");
        addDepartment.setBounds(220,5,200,30);

        panel.add(addDepartment);
   //     removeEmployee = new JButton("Удалить сотрудника");
   //     removeEmployee.setBounds(220, 5, 200, 30);
   //     panel.add(removeEmployee);
      //  getEmployee = new JButton("Получить сотрудника по id");
    //    getEmployee.setBounds(5, 80, 200, 30);
    //    panel.add(getEmployee);

        employeeList = new JButton("Список сотрудников");
        employeeList.setBounds(5,50,200,30);
        panel.add(employeeList);

        employeeList.addActionListener(new LoaderList());

        departmentList = new JButton("Список отделов");
         departmentList.setBounds(220,50,200,30);
        panel.add(departmentList);

        departmentList.addActionListener(new LoaderDepartments());

        saveList = new JButton("Сохранить список");
        saveList.setBounds(5, 100, 200, 30);
        panel.add(saveList);


        saveList.addActionListener(new Saver());

        loadlist = new JButton("Загрузить список");
        loadlist.setBounds(220, 100, 200, 30);
        panel.add(loadlist);


        loadlist.addActionListener(new Loader());



      //  removeEmployee.addActionListener(new Delete());


        panel.validate();
       addDepartment.addActionListener(new AddDepartment());

           this.add(panel);
        setPreferredSize(new Dimension(500, 800));
        
     //   this.setVisible(true);
        

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    }


    public void addActionListnerForAdd(ActionListener addlistner)
    {
        addEmployee.addActionListener(addlistner);
    }


    public void addListnerForAddTwo(ActionListener addlist)
    {
        addEmployeeTwo.addActionListener(addlist);
    }

    public void addActionForSave(ActionListener saver)
    {
        saveList.addActionListener(saver);
    }


    public void addActionForLoad(ActionListener loader)
    {
        loadlist.addActionListener(loader);
    }



    public int getSelect()
    {
        return select;
    }


    public void addFormsForNewEmployee ()
    {



    }


    public Employee readnewEmployee()
    {
       /* Employee emp = new Employee();
        String name1 = name.getText();
        String namesur =surname.getText();
        String namelast = lastname.getText();
        String depart = department.getText();
        String pay1 = pay.getText();
        String phone1 = phone.getText();
        if(name1!=null&& namesur!=null&& namelast!=null && depart!=null&&pay.getText()!=null&& phone.getText()!=null)
        {
            emp.setName(name1);
            emp.setSurname(namesur);
            emp.setLastName(namelast);
            emp.setDepartment(new Department(depart,null));
            emp.setPay(pay1);
            emp.setPhoneNumber(phone1);
        }
        return emp;   */   return null;

    }

    public void printlist()
    {
     /* //  ArrayList<Employee> mod = model.getList();

        list.setText("");
        //for(int i =0;i< mod.size();i++)
        {
          //  Employee emp = mod.get(i);
          //  list.append(emp.getName()+ " ");
            list.append(emp.getSurname()+" ");
            list.append(emp.getLastName()+" ");
            list.append(emp.getDepartment().getName()+" ");
            list.append(new Integer(emp.getPay()).toString()+" ");
            list.append(new Integer(emp.getPhoneNumber()).toString()+" \n");
        }
        panel.validate();
                              */
    }

    public void changeCount()
    {

       // Label.setText("Текущее количество сотрудников:" + model.getCount());
        panel.validate();
    }



}




